home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2007 May / PCpro_2007_05.ISO / files / vollversionen / visualdataflex / VDF12.0.StudioDownload.exe / %MAINDIR% / Examples / Example Library / AppSrc / Test.src < prev   
Encoding:
Text File  |  2007-03-10  |  5.3 KB  |  146 lines

  1. //  TestProject for Windows application
  2. //
  3.  
  4. Use DfAllent.pkg
  5. Object oHtmlHelp is a cHtmlHelp
  6. End_Object
  7.  
  8. Object oApplication is a cApplication
  9.     Set pbPreserveEnvironment to False
  10.     Set peHelpType to htHtmlHelp
  11. End_Object  // oApplication
  12.  
  13. Object oMain is a Panel
  14.  
  15.     Property Handle phoViewMenu 0
  16.     Property Handle phoReportMenu 0
  17.  
  18.     Set Label To "My Project"
  19.     Set Location to 4 30
  20.     Set Size to 300 400
  21.  
  22.  
  23.     DFCreate_Menu Main_Menu
  24.         #INCLUDE File_pm.inc
  25.  
  26.         DFCreate_Menu "&View" ViewPopupMenu is a ViewPopupMenu
  27.             Set phoViewMenu to self // Setting this in the panel is used for test view auto-activation
  28.         End_Pull_Down
  29.  
  30.         Set Status_Help To "Available Views"
  31.  
  32.         DFCreate_Menu "&Report" ReportPopupMenu is a ViewPopupMenu
  33.             Set phoReportMenu to self  // Setting this in the panel is used for test view auto-activation
  34.         End_Pull_Down
  35.  
  36.         Set Status_Help To "Available Reports"
  37.  
  38.         #INCLUDE Navi_pm.inc
  39.         #INCLUDE Win_pm.inc
  40.         #INCLUDE Helpa_pm.inc
  41.     End_Menu  // Main_Menu
  42.  
  43.  
  44.     Use DefaultToolbar.pkg //  Tool-Bar object.
  45.  
  46.     Object oClientArea is a ClientArea
  47.  
  48.         Use Dd_debug.dg // This Provides access to dd debugger by pressing ctrl+d within any view. Good for debugging
  49.  
  50.     End_Object  // oClientArea
  51.  
  52.     Use DefaultStatusbar.pkg //  Status-Bar object.
  53.  
  54.     Use StdAbout.pkg
  55.  
  56.     Procedure Activate_About
  57.         Send DoAbout "Test Windows Projects" "0.0.0" "" "" ""
  58.     End_Procedure
  59.  
  60.     //
  61.     // All of the code below are methods and augmentations which makes this work well as a test program. This:
  62.     // 1. Supports an auto-activate feature where all dialogs in the view and report menu are activated upon startup
  63.     // 2. forces the panel to resize if it is not large enough to accomodate all of the views.
  64.     // This code was placed directly in the testproject template and, therefore, directly in the .src file so
  65.     // a developer can easily modify this to fit their own needs. It is not expected that these techniques would
  66.     // get used in actual deployed projects.
  67.     //
  68.  
  69.     // special test component code to activate all views and reports. For testing we assume
  70.     // that you want to see everything.
  71.  
  72.     Procedure AutoActivate
  73.         handle hoMenu
  74.         Integer iItems i
  75.  
  76.         // this activates all views from the view menu
  77.         Get phoViewMenu to hoMenu
  78.         If hoMenu begin
  79.            Get Item_count of hoMenu to iItems
  80.            For i from 0 to (iItems-1)
  81.                Set Current_Item of hoMenu to i
  82.                Send Redirect_Message of hoMenu
  83.            Loop
  84.         end
  85.  
  86.         // this activates all views from the report view menu
  87.         Get phoReportMenu to hoMenu
  88.         If hoMenu begin
  89.            Get Item_count of hoMenu to iItems
  90.            For i from 0 to (iItems-1)
  91.                Set Current_Item of hoMenu to i
  92.                Send Redirect_Message of hoMenu
  93.            Loop
  94.         end
  95.     End_Procedure
  96.  
  97.  
  98.     // This checks all views within the client area to make sure that they fit within
  99.     // the client area. If not we will adjust the main panel so everything fits. This
  100.     // can only be done after the objects are all activated.
  101.  
  102.     Procedure MakeGoodPanelSize
  103.         Handle hoView hoClient
  104.         Integer iSize iLoc iHeight iWidth iOldSize
  105.         Get Client_Id to hoClient
  106.         If hoClient begin
  107.             Get GuiSize of hoClient to iOldSize  // starting size of client area
  108.             Move (Hi(iOldSize)) to iHeight
  109.             Move (Low(iOldSize)) to iWidth
  110.             // for each mdi client see if it fits, keep track of largest size needed
  111.             Get Next_Mdi_Dialog of hoClient True to hoView // find first
  112.             While (hoView)
  113.                 Get GuiSize of hoView to iSize    // size of view
  114.                 Get GuiLocation of hoView to iLoc // location of view
  115.                 Move (hi(iSize)+hi(iLoc)+10 max iHeight)  to iHeight // max height needed (+10 is for wiggle room)
  116.                 Move (low(iSize)+low(iLoc)+10 max iWidth) to iWidth  // max width needed
  117.                 Get Next_Mdi_Dialog of hoClient False to hoView // find next view
  118.             Loop
  119.             Move (iHeight-hi(iOldSize) max 0) to iHeight // get delta compared to old size. We want delta
  120.             Move (iWidth-low(iOldSize) max 0) to iWidth  // only if the new size is bigger (i.e., > 0)
  121.             If  (iHeight>0 or iWidth>0) begin
  122.                 Get GuiSize to iOldSize // now add the delta to the panel size
  123.                 Set GuiSize to (hi(iOldSize)+iHeight) (low(iOldSize)+iWidth)
  124.                 Send Adjust_Logicals // adjust from gui to regular size
  125.             end
  126.         end
  127.     End_Procedure
  128.  
  129.     // special test program  augmentation which opens all views and report views and
  130.     // makes sure that the size of the panel is big enough
  131.  
  132.     Procedure End_Construct_Object
  133.         Boolean bAutoActivate
  134.         Get Auto_Activate_State to bAutoActivate
  135.         Forward send End_Construct_Object
  136.         If bAutoActivate begin
  137.             Send AutoActivate       // activate all views and report views
  138.             send MakeGoodPanelSize  // make sure the panel is big enough for all of this
  139.         end
  140.     End_Procedure
  141.  
  142. End_Object  // oMain
  143.  
  144. Start_UI
  145.  
  146.